Repository navigation
test(formatting): isolate Colors state in disable tests (REGE #34) - #44
Conversation
…ests Colors.disable() blanks every uppercase attribute, but test_colors_disable (test_formatting.py) and test_colors_disable_sets_empty_strings (test_formatting_coverage.py) saved and restored only RED/RESET. The remaining attributes (GREEN, YELLOW, BLUE, BOLD_*, DIM, ...) stayed blanked for the rest of the process, so any later test asserting on them failed depending on execution order — e.g. TestColors::test_colors_defined after test_colors_disable, and TestFormattingNoColor:: test_no_color_env_triggers_disable (precondition Colors.GREEN != '') after test_formatting.py. Both tests now snapshot the full Colors class dict and restore it in a finally block. Test-local isolation only; Colors.disable() semantics and all production code are untouched. Refs #34.
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait...
|
Reviewer's GuideTestsUpdate both Colors.disable() tests to snapshot all uppercase class attributes and restore them in a finally block, preventing state leaks into later tests.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |

Refs #34 — executes the implementation plan posted on the issue (verified against main
1ef23911, which is still the current main head).Defect (reproduced at declared dependencies)
Colors.disable()blanks every uppercase attribute, but the two tests that exercise it saved and restored onlyRED/RESET:rege/tests/test_formatting.py::TestColors::test_colors_disablerege/tests/test_formatting_coverage.py::TestColorsDisable::test_colors_disable_sets_empty_stringsThe other attributes (
GREEN,YELLOW,BLUE,BOLD_*,DIM, ...) stayed""for the rest of the process, so any later test asserting on them failed depending on execution order. This is the census's "shared state surviving an earlier disabling test". The defect is invisible in default collection order (the victims happen to run first), which is why main CI is green.Fix
Test-local isolation only, per the plan: both tests now snapshot the full
Colorsclass dict beforedisable()and restore it in afinallyblock.Colors.disable()semantics and all production code are untouched. No dependency or CI changes.Evidence — environment
Disposable venv,
pip install -e ".[dev]", Python 3.12.3, resolved: click 8.5.1 (>=8.5.0 declared), pytest 9.2.0 (>=9.2.0), pytest-cov 7.1.0. (The census ran click 8.1.8 / pytest 9.0.2, below the declared floor.)Evidence — isolation matrix (same process, forced orders)
1ef23911)test_colors_definedalonetest_colors_disable->test_colors_definedColors.GREEN == '')test_colors_disable_sets_empty_strings->test_colors_definedtest_formatting.py+test_formatting_coverage.py+test_bloom_misc_final_coverage.pytest_no_color_env_triggers_disablepreconditionColors.GREEN != "")timeout 120Evidence — full suite (no deselects, JUnit recorded)
Files changed
rege/tests/test_formatting.py— full-state snapshot/restore intest_colors_disablerege/tests/test_formatting_coverage.py— same intest_colors_disable_sets_empty_stringsDraft — merge is Anthony's call.
Summary by Sourcery
Enhancements: